package de.jmda.gen.java.impl;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import de.jmda.gen.GeneratorException;
import de.jmda.gen.LineIndenter;
import de.jmda.gen.java.TypeBodyGenerator;

public class JUT_DefaultTypeBodyGenerator
{
	@Test
	public void testDefaultTypeBodyGenerator() throws GeneratorException
	{
		TypeBodyGenerator generator = new DefaultTypeBodyGenerator();

		StringBuffer generated = generator.generate();

		System.out.println(generated);

		assertEquals
		(
				"{" + System.lineSeparator() +
				"}",
				generated.toString()
		);
	}

	@Test
	public void testWithInstanceMethod() throws GeneratorException
	{
		TypeBodyGenerator generator = new DefaultTypeBodyGenerator();
		
		DefaultInstanceMethodDeclarationsGenerator methodDeclarationsGenerator =
				new DefaultInstanceMethodDeclarationsGenerator();
		
		DefaultInstanceMethodDeclarationGenerator methodDeclarationGenerator =
				new DefaultInstanceMethodDeclarationGenerator(
						new DefaultDeclaredInstanceMethodGenerator(
								new DefaultMethodModifiersGenerator(),
								new DefaultTypeNameGenerator(),
								new DefaultMethodNameGenerator(),
								new DefaultMethodParametersGenerator(),
								new DefaultThrowsClauseGenerator(),
								new DefaultMethodBodyGenerator()));
		
		generator.setInstanceMethodDeclarationsGenerator(
				methodDeclarationsGenerator);
		methodDeclarationsGenerator.add(methodDeclarationGenerator);
		methodDeclarationsGenerator.setLineIndenter(new LineIndenter("\t", 1));

		StringBuffer generated = generator.generate();

		System.out.println(generated);

		assertEquals
		(
				"{" + System.lineSeparator() +
				methodDeclarationsGenerator.generate() + System.lineSeparator() +
				"}",
				generated.toString()
		);
	}

//	@Test
//	public void testWithStaticMethod() throws GeneratorException
//	{
//		TypeBodyGenerator generator = new DefaultTypeBodyGenerator();
//		
//		DefaultStaticMethodDeclarationsGenerator methodDeclarationsGenerator =
//				new DefaultStaticMethodDeclarationsGenerator();
//		
//		DefaultStaticMethodDeclarationGenerator methodDeclarationGenerator =
//				new DefaultStaticMethodDeclarationGenerator(
//						new DefaultTechnicalStaticMethodDeclarationGenerator(
//								new DefaultMethodModifiersGenerator(),
//								new DefaultTypeNameGenerator(),
//								new DefaultMethodNameGenerator(),
//								new DefaultMethodParameterListGenerator(),
//								new DefaultMethodBodyGenerator()));
//		
//		generator.setStaticMethodDeclarationsGenerator(
//				methodDeclarationsGenerator);
//		methodDeclarationsGenerator.add(methodDeclarationGenerator);
//
//		StringBuffer generated = generator.generate();
//
//		System.out.println(generated);
//
//		assertEquals
//		(
//				"{" + System.lineSeparator() +
//				methodDeclarationsGenerator.generate() + System.lineSeparator() +
//				"}",
//				generated.toString()
//		);
//	}
}